/**
 * @name Find Symbol References
 * @kind problem
 * @problem.severity info
 * @description Finds all references to a given symbol (function, class, variable)
 * @id cpp/find-references
 */

import cpp

from FunctionCall call, Function target
where target.getName().matches("%${symbolName}%")
  and call.getTarget() = target
  // 排除标准库
  and not target.getFile().getRelativePath().matches("%/usr/%")
  and not call.getFile().getRelativePath().matches("%/usr/%")
select 
  call.getFile().getRelativePath() as filePath,
  call.getLocation().getStartLine() as line,
  call.getLocation().getStartColumn() as column,
  call.getEnclosingFunction().getName() as callerFunction,
  target.getName() as targetName,
  "Reference to " + target.getName() + " at " + call.getFile().getRelativePath() + ":" + call.getLocation().getStartLine()

